﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="ProductSales.aspx.cs" Inherits="XYZ_Inventory.ProductSales" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="Styles/GridView.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/ValidationSummary.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/CustomTable.css" rel="stylesheet" type="text/css"/>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <fieldset style="margin: 0.5em; padding: 0.5em;">
                <legend>Product Sales</legend>
                <div class="gridViewContainer" style="float: left;">
                    <asp:GridView ID="GridView1" CssClass="gridView" runat="server" AllowPaging="True"
                                  AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
                                  GridLines="None" DataKeyNames="SalesID" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                                  OnRowDeleting="GridView1_RowDeleting"
                                  OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"
                                  onpageindexchanging="GridView1_PageIndexChanging">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                        <Columns>
                            <asp:BoundField DataField="SalesID" HeaderText="Sales ID" ReadOnly="True"/>
                            <asp:BoundField DataField="Product" HeaderText="Product Name" ReadOnly="True"/>
                            <asp:BoundField DataField="DateAndTime" HeaderText="Date" ReadOnly="True" DataFormatString="{0:d}"/>
                            <asp:TemplateField HeaderText="Quantity">
                                <ItemTemplate>
                                    <%# Eval("Quantity") %>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtQty" runat="server" min="1" TextMode="Number" Width="75" Text='<%# Eval("Quantity") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtQty"
                                                                ErrorMessage="Unit selling price is required." Text="*" ForeColor="Red" Display="Dynamic"
                                                                ValidationGroup="Edit">
                                    </asp:RequiredFieldValidator>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Actions" ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                                    Text="Update" ValidationGroup="Edit">
                                    </asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                                          Text="Cancel">
                                    </asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                                    Text="Edit">
                                    </asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                                                          Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');">
                                    </asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#999999"/>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
                        <SortedAscendingCellStyle BackColor="#E9E7E2"/>
                        <SortedAscendingHeaderStyle BackColor="#506C8C"/>
                        <SortedDescendingCellStyle BackColor="#FFFDF8"/>
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
                    </asp:GridView>
                    <asp:ValidationSummary ID="ValidationSummary2" Style="margin-top: 1em;" CssClass="validationSummary"
                                           HeaderText="<b>Please fix following error(s):</b>" ValidationGroup="Edit" ForeColor="Red"
                                           runat="server"/>
                </div>
                <table class="table" style="float: left; padding-left: 1em;">
                    <tr>
                        <th colspan="2">
                            Sell products
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label2" runat="server" Text="Product"></asp:Label>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlProduct" runat="server" DataSourceID="ProductSource" DataTextField="Name"
                                              DataValueField="ProductID">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="Label3" runat="server" Text="Quantity"></asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtQty" runat="server" min="1" Width="75" TextMode="Number"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtQty"
                                                        ErrorMessage="Product quantity is required." Text="*" ForeColor="Red" Display="Dynamic"
                                                        ValidationGroup="Sell">
                            </asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="background-color: #E2DED6; color: #284775;">
                            <asp:Button ID="btnAdd" runat="server" ValidationGroup="Sell" Text="Sell" OnClick="btnAdd_Click"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="background-color: #E2DED6; color: #284775;">
                            <asp:ValidationSummary ID="ValidationSummary1" CssClass="validationSummary" HeaderText="<b>Please fix following error(s):</b>"
                                                   ValidationGroup="Sell" ForeColor="Red" runat="server"/>
                            <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <asp:EntityDataSource ID="ProductSource" runat="server" ConnectionString="name=XYZDBContext"
                                  DefaultContainerName="XYZDBContext" EnableFlattening="False" EntitySetName="FinishedProductInventories"
                                  EntityTypeFilter="FinishedProductInventory" Select="it.[ProductID], it.[Name]">
            </asp:EntityDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>